//
//  WZTabBarButton.m
//  ETong
//
//  Created by wanzhao on 15/10/28.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZTabBarButton.h"

@interface WZTabBarButton ()

WeakProperty UIView *line;

@end

@implementation WZTabBarButton


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.imageView.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.backgroundColor = ClearColor;
        [self setExclusiveTouch:YES];/*禁用按钮同时点击*/
        
//        UIView *line = [[UIView alloc] init];
//        line.hidden = YES;
//        line.backgroundColor = RGBCOLOR(44, 170, 253);
//        [self addSubview:line];
//        self.line = line;
        
        
    }
    return self;
}

- (void)setItem:(UITabBarItem *)item
{
    _item = item;

}
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imgX = 0;
    CGFloat imgY = self.contentEdgeInsets.top;
    CGFloat imgW = self.width;
    CGFloat imgH = self.currentImage.size.height;
    return CGRectMake(imgX, imgY, imgW, imgH);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat titleX = 0;
    CGFloat titleY = self.currentImage.size.height + self.contentEdgeInsets.top + 5.0f;
    CGFloat titleW = self.width;
    CGFloat titleH = self.height - self.currentImage.size.height - self.contentEdgeInsets.top;
    return CGRectMake(titleX, titleY, titleW, titleH);
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
//    self.line.hidden = !selected;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
//    self.line.frame = CGRectMake(0, self.height - 3.0f, self.width, 3.0f);
}
@end
